package com.sdtv.basemodule.image;

import android.widget.ImageView;

/**
 * @ProjectName: MediunFusion
 * @Package: com.sdtv.basemodule.image
 * @ClassName: ImageConfig
 * @Description: 图片的配置文件类
 * 用来设置图片的基本数据
 * @Author: 小郭同学
 * @CreateDate: 2019-07-08 16:36
 * @UpdateRemark: 更新说明
 * @Version: 1.0
 */
public class ImageConfig {
    // 加载图片默认图
    private int defaultImgId;
    // 加载失败默认图
    private int errorImgId;
    // 默认图片圆角角度
    private int radius;
    // 图片宽度
    private int width;
    // 图片高度
    private int height;
    // 图片展示样式
    private ImageView.ScaleType scaleType;


    public static Builder build() {
        return new Builder();
    }

    public ImageConfig(Builder builder) {
        this.defaultImgId = builder.defaultImgId;
        this.errorImgId = builder.errorImgId;
        this.radius = builder.radius;
        this.width = builder.width;
        this.height = builder.height;
        this.scaleType = builder.scaleType;
    }

    public int getDefaultImgId() {
        return defaultImgId;
    }

    public void setDefaultImgId(int defaultImgId) {
        this.defaultImgId = defaultImgId;
    }

    public int getErrorImgId() {
        return errorImgId;
    }

    public void setErrorImgId(int errorImgId) {
        this.errorImgId = errorImgId;
    }

    public int getRadius() {
        return radius;
    }

    public void setRadius(int radius) {
        this.radius = radius;
    }

    public int getWidth() {
        return width;
    }

    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    public ImageView.ScaleType getScaleType() {
        return scaleType;
    }

    public void setScaleType(ImageView.ScaleType scaleType) {
        this.scaleType = scaleType;
    }

    /**
     * 构造者模式
     * <p>
     * 构建工具
     */
    public static class Builder {
        // 加载图片默认图
        private int defaultImgId;
        // 加载失败默认图
        private int errorImgId;
        // 默认图片圆角角度
        private int radius;
        // 图片宽度
        private int width;
        // 图片高度
        private int height;
        //图片显示模式
        private ImageView.ScaleType scaleType;

        public ImageConfig build() {
            return new ImageConfig(this);
        }

        public Builder defaultImg(int defaultImgId) {
            this.defaultImgId = defaultImgId;
            return this;
        }

        public Builder errorImg(int errorImgId) {
            this.errorImgId = errorImgId;
            return this;
        }

        public Builder radius(int radius) {
            this.radius = radius;
            return this;
        }

        public Builder width(int width) {
            this.width = width;
            return this;
        }

        public Builder height(int height) {
            this.height = height;
            return this;
        }

        public Builder scaleType(ImageView.ScaleType scaleType) {
            this.scaleType = scaleType;
            return this;
        }

    }


}
